import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { PropTypes } from 'prop-types';
import './index.scss'

export default class MessageItem extends Taro.Component {
    static defaultProps = {
        messageItem: {}
    }
    goMessageDetail(){
        Taro.navigateTo({
            url: `/pages/message/messageDetails/index?id=${this.props.messageItem.id}`
        })
    }
    render() {
        let { messageItem } = this.props;
        // <Text className='fc_960'>公告：</Text>
        return (
            <View className='message-item mt-2-5 pl-4 pr-4 pt-3 pb-3 box_s' onClick={()=>{this.goMessageDetail()}} >
                <View className='flex flex-r flex-item-between'>
                    <View className='ft28 ecs'><Text className={messageItem.content_type === '1' ? 'fc_FF8' : 'fc_960'}>{messageItem.content_type === '1' ? '提醒' : '公告'}：</Text>{messageItem.title || "-"}</View>
                    <View className='fc_999 ft24'>{messageItem.timesString}</View>
                </View>
                <View className='ft24 fc_666 pt-2-5 ecs'>{messageItem.content}</View>
            </View>
        )
    }
}
MessageItem.propTypes = {
    messageItem: PropTypes.object
}